package com.jh.paymentchannel.repository;

import java.util.List;

import com.jh.paymentchannel.pojo.HLRegister;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

public interface HLRegisterRepository extends  JpaRepository<HLRegister,Integer>,JpaSpecificationExecutor<HLRegister>{
	
	List<HLRegister> findByUserId(String userId);

	HLRegister findHLRegisterByBankCard(String bankCard);

	HLRegister findByBindId(String bindId);

	HLRegister findByBindIdAndBankCard(String bindId, String bankCard);
	@Query("select o from HLRegister o where o.userId=:userId")
	List<HLRegister> findByUserIdList(@Param("userId") String userId);
	
	//注销用户记录
	@Modifying
	@Query("delete from HLRegister o where o.userId=:userid")
	void delHLRegisterByUserid(@Param("userid") String userid);
	
	
	@Query("select o from HLRegister o where o.bankCard=:bankCard and o.cardType=:cardType")
	HLRegister findByBankCardAndCardType(@Param("bankCard") String bankCard, @Param("cardType") String cardType);
	
	@Query("select o from HLRegister o where o.phone=:phone and o.cardType=:cardType")
	HLRegister findByPhoneAndCardType(@Param("phone") String phone, @Param("cardType") String cardType);
	
}
